package com.ruoyi.zhmk.service;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.faceApi.click.IFaceCallBack;
import com.ruoyi.faceApi.entity.FaceIdentification;
import org.springframework.context.ApplicationContext;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: wwy
 * @Date: 2021/6/23 14:51
 */
public class FaceCallBack implements IFaceCallBack {
    public static ApplicationContext applicationContext;
    @Override
    public void invoke(FaceIdentification faceIdentification) {
        //存在名字进行保存
        if(StringUtils.isEmpty(faceIdentification.getPersonId()) || StringUtils.isEmpty(faceIdentification.getName())){
            //不进行保存
            return;
        }
        IZhmkUserinoutInfoService zhmkUserinoutService = applicationContext.getBean(IZhmkUserinoutInfoService.class);
        Map<String,Object> map = new HashMap<>();
        //判断是否为请假人员，修改请假记录
        if(StringUtils.isNotEmpty(faceIdentification.getPersonId())){
            IZhmkAskService zhmkAskService = applicationContext.getBean(IZhmkAskService.class);
            zhmkAskService.askOpinion(faceIdentification,map);
        }
        zhmkUserinoutService.addZhmkUserInfo(faceIdentification,map);
    }
}
